<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>微信小程序支付</title>
		<style type="text/css">
			.btn {
				display: block;
				margin: 20px auto;
				padding: 5px;
				background-color: #007aff;
				border: 0;
				color: #ffffff;
				height: 40px;
				width: 200px;
			}

			.btn-red {
				background-color: #dd524d;
			}
		</style>
	</head>
	<body>
		<div class="">
			<div class="btn-list">
				<button class="btn btn-red" type="button" id="launchMini">去微信小程序支付</button>
			</div>
		</div>
		<!-- <div class="btn-list">
			<button class="btn navigateBack" type="button" data-action="navigateBack">返回uniapp的小程序界面</button>
		</div> -->
		<!-- uni 的 SDK -->
		<script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script>
		<script type="text/javascript">
			// 待触发 `UniAppJSBridgeReady` 事件后，即可调用 uni 的 API。
			document.addEventListener('UniAppJSBridgeReady', function() {
				document.getElementById('launchMini').addEventListener('click', function() {
					plus.share.getServices(function(res) {
						var sweixin = null;
						for (var i = 0; i < res.length; i++) {
							var t = res[i];
							if (t.id == 'weixin') {
								sweixin = t;
							}
						}

						if (sweixin) {
              let href = window.location.href
              let strObj = href.split('?')[1]
              let orderCd = strObj.split('&')[0].split('=')[1]
              let sign = strObj.split('&')[1].split('=')[1]
              console.log(strObj)
              console.log(orderCd)
              console.log(sign)
              let path = 'pages/index/index?orderCd='+orderCd+'&sign='+sign
              console.log('查看小程序路径', path)
							sweixin.launchMiniProgram({
								id: 'gh_5ef9306a314f',
								path,
								type: 0
							});
						}
					}, function(res) {
						console.log(JSON.stringify(res));
					});
				});
				// document.querySelector('.navigateBack').addEventListener('click', function(evt) {
				// 	uni.navigateBack({
				// 		delta: 1
				// 	});
				// });
			});
		</script>
	</body>
</html>
